package com.education.teach.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import dn.easy.common.constant.Contans;

public class FileUtils {

    public static boolean createDir(String destDirName) {
        File dir = new File(destDirName);
        if (dir.exists())
            return true;

        if (!destDirName.endsWith(File.separator))
            destDirName = destDirName + File.separator;
        //创建目录
        if (dir.mkdirs())
            return true;
        else
            return false;
    }

    public static boolean savePdfFile(String fileName, byte[] bytes) throws IOException {
        if (createDir(Contans.PDFLOCATION)) {
            FileOutputStream out = new FileOutputStream(fileName);
            out.write(bytes);
            out.close();
            return true;
        }
        return false;
    }
}
